import requests
import random

# 先去admin 创建5个用户
players = [1, 2, 3, 4, 5]


def send_score():
    player = random.choice(players)
    print(player)
    score = random.randint(0, 10000000)
    print(score)
    data = {
        "score": score,
        "client_no": player
    }
    r = requests.post('http://127.0.0.1:8000/interview/score', data=data)
    print(r.json())


def get_charts():
    player = random.choice(players)
    print(player)
    start = random.randint(0, len(players))
    print(start)
    end = random.randint(start, len(players))
    print(end)
    start = 0
    end = 10

    params = {
        'client_no': player,
        'start': start,
        'end': end,
    }
    r = requests.get('http://127.0.0.1:8000/interview/charts', params=params)
    print(r.json())
    pass


if __name__ == '__main__':
    pass
    for i in range(10):
        send_score()
    get_charts()
